package com.gzx.plugin.tjzy.modular.blacklist.controller;

import com.gzx.plugin.tjzy.modular.blacklist.bo.GzxBlackListAddBo;
import com.gzx.plugin.tjzy.modular.blacklist.bo.GzxBlackListQueryBo;
import com.gzx.plugin.tjzy.modular.blacklist.dto.GzxBlackRespDto;
import com.gzx.plugin.tjzy.modular.blacklist.service.GzxBlackListService;
import com.gzx.plugin.tjzy.modular.blacklist.vo.GzxBlackListVo;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.mvc.controller.BaseController;
import vip.xiaonuo.common.pojo.CommonResult;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author xbl
 */
@RestController
@RequestMapping("/tjzy/blacklist")
public class GzxBlackListController extends BaseController<GzxBlackListAddBo, GzxBlackListVo, GzxBlackListQueryBo, GzxBlackListService> {


    public GzxBlackListController(GzxBlackListService baseService) {
        super(baseService);
    }

    @CommonLog("黑名单导入")
    @PostMapping("/importExcel")
    public CommonResult<String> importExcel(@RequestPart("blacklistAddBo") GzxBlackListAddBo bo, @RequestPart("multipartFile") MultipartFile multipartFile) {
        return CommonResult.data(baseService.importExcel(bo, multipartFile));
    }

    @GetMapping("/verifyBlack/{phone}")
    public CommonResult<List<GzxBlackRespDto.DataResp>> verifyBlack(@PathVariable String phone) {
        return CommonResult.data(baseService.verifyBlack(new ArrayList<>(Collections.singleton(phone))));
    }
}
